{% extends "nomcom/nomcom_private_base.html" %}
{# Copyright The IETF Trust 2015-2023, All Rights Reserved #}
{% load origin %}
{% load nomcom_tags textfilters %}
{% block subtitle %}- View unrelated feedback{% endblock %}
{% block nomcom_content %}
{% origin %}
{% if reclassify_feedback %}
    {% include "nomcom/reclassify_feedback_item.html" %}
{% else %}
    <h2>Feedback not related to nominees</h2>
    <ul role="tablist" class="nav nav-tabs my-3">
        {% for ft in feedback_types %}
            <li class="nav-item">
                <button class="nav-link {% if forloop.first %}active{% endif %}"
                        data-bs-target="#{{ ft.ft.slug }}"
                        role="tab" type="button"
                        data-bs-toggle="tab">
                    {{ ft.ft.name }}
                </button>
            </li>
        {% endfor %}
    </ul>
    <div class="tab-content">
        {% for ft in feedback_types %}
            <div role="tabpanel" class="tab-pane {% if forloop.first %} active{% endif %}"
                 id="{{ ft.ft.slug }}">
                {% for feedback in ft.feedback %}
                    {% if not forloop.first %}
                        <hr>
                    {% endif %}
                    <dl class="row">
                        <dt class="col-sm-2">
                            From
                        </dt>
                        <dd class="col-sm-10">
                            {{ feedback.author|formatted_email|default:"Anonymous"|linkify }}
                        </dd>
                        <dt class="col-sm-2">
                            Date
                        </dt>
                        <dd class="col-sm-10">
                            {{ feedback.time|date:"Y-m-d" }}
                        </dd>
                        <dt class="col-sm-2">
                            Feedback
                        </dt>
                        <dd class="col-sm-10 pasted">
                            <pre>{% decrypt feedback.comments request year 1 %}</pre>
                        </dd>
                        {% if user|is_chair_or_advisor:year %}
                        <dt class="col-sm-2">
                            <form id="reclassify-{{ feedback.id }}" method="post">
                                {% csrf_token %}
                                <input type="hidden" name="feedback_id" value="{{ feedback.id }}">
                                <button class="btn btn-warning btn-sm" type="submit">
                                    Reclassify
                                </button>
                            </form>
                        </dt>
                        <dd>
                        </dd>
                        {% endif %}
                    </dl>
                {% endfor %}
            </div>
        {% endfor %}
    </div>
    <p>
        <a class="btn btn-secondary"
           href="{% url 'ietf.nomcom.views.view_feedback' year %}">Back</a>
    </p>
{% endif %}
{% endblock %}
{% block js %}
    <script>
        $(document)
            .ready(function () {
                // Javascript to enable link to tab
                var url = document.location.toString();
                if (url.match('#')) {
                    $('.nav-tabs button[data-bs-target="#' + url.split('#')[1] + '"]')
                        .tab('show');
                }
                // Change hash for page-reload
                $('.nav-tabs button')
                    .on('shown.bs.tab', function (e) {
                        history.replaceState(null, null, e.currentTarget.dataset.bsTarget);
                    });
            });
    </script>
{% endblock %}
